// src\redux\store.js
// 管理整个项目中所有的reducer
import { createStore } from 'redux';
import {CollApsedReducer} from './reducers/CollapsedReducer';
import { LoadingReducer } from './reducers/LoadingReducer';
import persistReducer from 'redux-persist/es/persistReducer';
import persistStore from 'redux-persist/es/persistStore';
import storage from 'redux-persist/lib/storage' // defaults to localStorage for web
const { combineReducers } = require("redux");

// 可以整合多个reducer
const reducer=combineReducers({
    CollApsedReducer,
    LoadingReducer
})
// 持久化
const persistConfig={
    key:"myStore",//将store存在localStorage中的键值
    storage,
    //若是LoadingReducer不需要实现持久化，可以将其放在blacklist黑名单中
    blacklist:['LoadingReducer'],
}
// 持久化
const persistedReducer=persistReducer(persistConfig,reducer);
const store=createStore(persistedReducer);
const persistor=persistStore(store);
export {store,persistor};
